home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2011 May / PC Advisor 190 E.iso / pc / ESSENTIALS / VLC Media Player 1.1 / vlc-1.1.5-win32.exe / sdk / include / vlc / plugins / vlc_vout.h < prev    next >
Encoding:
C/C++ Source or Header  |  2010-11-13  |  13.0 KB  |  353 lines

  1. /*****************************************************************************
  2.  * vlc_video.h: common video definitions
  3.  *****************************************************************************
  4.  * Copyright (C) 1999 - 2008 the VideoLAN team
  5.  * $Id: e739d93611b9fa43335963ba4735d2a6a0126fb3 $
  6.  *
  7.  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  8.  *          Samuel Hocevar <sam@via.ecp.fr>
  9.  *          Olivier Aubert <oaubert 47 videolan d07 org>
  10.  *
  11.  * This program is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 2 of the License, or
  14.  * (at your option) any later version.
  15.  *
  16.  * This program is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with this program; if not, write to the Free Software
  23.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  24.  *****************************************************************************/
  25.  
  26. #ifndef VLC_VOUT_H_
  27. #define VLC_VOUT_H_ 1
  28.  
  29. /**
  30.  * \file
  31.  * This file defines common video output structures and functions in vlc
  32.  */
  33.  
  34. #include <vlc_picture.h>
  35. #include <vlc_filter.h>
  36. #include <vlc_subpicture.h>
  37.  
  38. /**
  39.  * Video picture heap, either render (to store pictures used
  40.  * by the decoder) or output (to store pictures displayed by the vout plugin)
  41.  */
  42. struct picture_heap_t
  43. {
  44.     int i_pictures;                                   /**< current heap size */
  45.  
  46.     /* \name Picture static properties
  47.      * Those properties are fixed at initialization and should NOT be modified
  48.      * @{
  49.      */
  50.     unsigned int i_width;                                 /**< picture width */
  51.     unsigned int i_height;                               /**< picture height */
  52.     vlc_fourcc_t i_chroma;                               /**< picture chroma */
  53.     unsigned int i_aspect;                                 /**< aspect ratio */
  54.     /**@}*/
  55.  
  56.     /* Real pictures */
  57.     picture_t*      pp_picture[VOUT_MAX_PICTURES];             /**< pictures */
  58.     int             i_last_used_pic;              /**< last used pic in heap */
  59.     bool            b_allow_modify_pics;
  60.  
  61.     /* Stuff used for truecolor RGB planes */
  62.     uint32_t i_rmask; int i_rrshift, i_lrshift;
  63.     uint32_t i_gmask; int i_rgshift, i_lgshift;
  64.     uint32_t i_bmask; int i_rbshift, i_lbshift;
  65.  
  66.     /** Stuff used for palettized RGB planes */
  67.     void (* pf_setpalette) ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
  68. };
  69.  
  70. /*****************************************************************************
  71.  * Prototypes
  72.  *****************************************************************************/
  73.  
  74. /**
  75.  * Initialise different fields of a picture_t and allocates the picture buffer.
  76.  * \param p_this a vlc object
  77.  * \param p_pic pointer to the picture structure.
  78.  * \param i_chroma the wanted chroma for the picture.
  79.  * \param i_width the wanted width for the picture.
  80.  * \param i_height the wanted height for the picture.
  81.  * \param i_aspect the wanted aspect ratio for the picture.
  82.  */
  83. VLC_EXPORT( int, vout_AllocatePicture,( vlc_object_t *p_this, picture_t *p_pic, uint32_t i_chroma, int i_width, int i_height, int i_sar_num, int i_sar_den ) );
  84. #define vout_AllocatePicture(a,b,c,d,e,f,g) \
  85.         vout_AllocatePicture(VLC_OBJECT(a),b,c,d,e,f,g)
  86.  
  87. /**
  88.  * \defgroup video_output Video Output
  89.  * This module describes the programming interface for video output threads.
  90.  * It includes functions allowing to open a new thread, send pictures to a
  91.  * thread, and destroy a previously opened video output thread.
  92.  * @{
  93.  */
  94.  
  95. /**
  96.  * Video ouput thread private structure
  97.  */
  98. typedef struct vout_thread_sys_t vout_thread_sys_t;
  99.  
  100. /**
  101.  * Video output thread descriptor
  102.  *
  103.  * Any independent video output device, such as an X11 window or a GGI device,
  104.  * is represented by a video output thread, and described using the following
  105.  * structure.
  106.  */
  107. struct vout_thread_t
  108. {
  109.     VLC_COMMON_MEMBERS
  110.     bool                b_error;
  111.  
  112.     /** \name Thread properties and locks */
  113.     /**@{*/
  114.     vlc_mutex_t         picture_lock;                 /**< picture heap lock */
  115.     vlc_mutex_t         change_lock;                 /**< thread change lock */
  116.     vout_sys_t *        p_sys;                     /**< system output method */
  117.     /**@}*/
  118.  
  119.     /** \name Current display properties */
  120.     /**@{*/
  121.     uint16_t            i_changes;          /**< changes made to the thread.
  122.                                                       \see \ref vout_changes */
  123.     unsigned            b_fullscreen:1;       /**< toogle fullscreen display */
  124.     unsigned            b_autoscale:1;      /**< auto scaling picture or not */
  125.     unsigned            b_on_top:1; /**< stay always on top of other windows */
  126.     int                 i_zoom;               /**< scaling factor if no auto */
  127.     unsigned int        i_window_width;              /**< video window width */
  128.     unsigned int        i_window_height;            /**< video window height */
  129.     unsigned int        i_alignment;          /**< video alignment in window */
  130.  
  131.     /**@}*/
  132.  
  133.     /** \name Plugin used and shortcuts to access its capabilities */
  134.     /**@{*/
  135.     module_t *   p_module;
  136.     int       ( *pf_init )       ( vout_thread_t * );
  137.     void      ( *pf_end )        ( vout_thread_t * );
  138.     int       ( *pf_manage )     ( vout_thread_t * );
  139.     void      ( *pf_render )     ( vout_thread_t *, picture_t * );
  140.     void      ( *pf_display )    ( vout_thread_t *, picture_t * );
  141.     void      ( *pf_swap )       ( vout_thread_t * );         /* OpenGL only */
  142.     int       ( *pf_lock )       ( vout_thread_t * );         /* OpenGL only */
  143.     void      ( *pf_unlock )     ( vout_thread_t * );         /* OpenGL only */
  144.     int       ( *pf_control )    ( vout_thread_t *, int, va_list );
  145.     /**@}*/
  146.  
  147.     /** \name Video heap and translation tables */
  148.     /**@{*/
  149.     int                 i_heap_size;                          /**< heap size */
  150.     picture_heap_t      render;                       /**< rendered pictures */
  151.     picture_heap_t      output;                          /**< direct buffers */
  152.  
  153.     video_format_t      fmt_render;      /* render format (from the decoder) */
  154.     video_format_t      fmt_in;            /* input (modified render) format */
  155.     video_format_t      fmt_out;     /* output format (for the video output) */
  156.     /**@}*/
  157.  
  158.     /* Picture heap */
  159.     picture_t           p_picture[2*VOUT_MAX_PICTURES+1];      /**< pictures */
  160.  
  161.     /* Subpicture unit */
  162.     spu_t          *p_spu;
  163.  
  164.     /* Video output configuration */
  165.     config_chain_t *p_cfg;
  166.  
  167.     /* Private vout_thread data */
  168.     vout_thread_sys_t *p;
  169. };
  170.  
  171. #define I_OUTPUTPICTURES p_vout->output.i_pictures
  172. #define PP_OUTPUTPICTURE p_vout->output.pp_picture
  173. #define I_RENDERPICTURES p_vout->render.i_pictures
  174. #define PP_RENDERPICTURE p_vout->render.pp_picture
  175.  
  176. /** \defgroup vout_changes Flags for changes
  177.  * These flags are set in the vout_thread_t::i_changes field when another
  178.  * thread changed a variable
  179.  * @{
  180.  */
  181. /** b_info changed */
  182. #define VOUT_INFO_CHANGE        0x0001
  183. /** b_interface changed */
  184. #define VOUT_INTF_CHANGE        0x0004
  185. /** b_autoscale changed */
  186. #define VOUT_SCALE_CHANGE       0x0008
  187. /** b_on_top changed */
  188. #define VOUT_ON_TOP_CHANGE    0x0010
  189. /** b_cursor changed */
  190. #define VOUT_CURSOR_CHANGE      0x0020
  191. /** b_fullscreen changed */
  192. #define VOUT_FULLSCREEN_CHANGE  0x0040
  193. /** i_zoom changed */
  194. #define VOUT_ZOOM_CHANGE        0x0080
  195. /** size changed */
  196. #define VOUT_SIZE_CHANGE        0x0200
  197. /** depth changed */
  198. #define VOUT_DEPTH_CHANGE       0x0400
  199. /** change chroma tables */
  200. #define VOUT_CHROMA_CHANGE      0x0800
  201. /** cropping parameters changed */
  202. #define VOUT_CROP_CHANGE        0x1000
  203. /** aspect ratio changed */
  204. #define VOUT_ASPECT_CHANGE      0x2000
  205. /** change/recreate picture buffers */
  206. #define VOUT_PICTURE_BUFFERS_CHANGE 0x4000
  207. /**@}*/
  208.  
  209. /* Alignment flags */
  210. #define VOUT_ALIGN_LEFT         0x0001
  211. #define VOUT_ALIGN_RIGHT        0x0002
  212. #define VOUT_ALIGN_HMASK        0x0003
  213. #define VOUT_ALIGN_TOP          0x0004
  214. #define VOUT_ALIGN_BOTTOM       0x0008
  215. #define VOUT_ALIGN_VMASK        0x000C
  216.  
  217. #define MAX_JITTER_SAMPLES      20
  218.  
  219. /* scaling factor (applied to i_zoom in vout_thread_t) */
  220. #define ZOOM_FP_FACTOR          1000
  221.  
  222. /*****************************************************************************
  223.  * Prototypes
  224.  *****************************************************************************/
  225.  
  226. /**
  227.  * This function will
  228.  *  - returns a suitable vout (if requested by a non NULL p_fmt)
  229.  *  - recycles an old vout (if given) by either destroying it or by saving it
  230.  *  for latter usage.
  231.  *
  232.  * The purpose of this function is to avoid unnecessary creation/destruction of
  233.  * vout (and to allow optional vout reusing).
  234.  *
  235.  * You can call vout_Request on a vout created by vout_Create or by a previous
  236.  * call to vout_Request.
  237.  * You can release the returned value either by vout_Request or vout_Close()
  238.  * followed by a vlc_object_release() or shorter vout_CloseAndRelease()
  239.  *
  240.  * \param p_this a vlc object
  241.  * \param p_vout a vout candidate
  242.  * \param p_fmt the video format requested or NULL
  243.  * \return a vout if p_fmt is non NULL and the request is successfull, NULL
  244.  * otherwise
  245.  */
  246. VLC_EXPORT( vout_thread_t *, vout_Request, ( vlc_object_t *p_this, vout_thread_t *p_vout, video_format_t *p_fmt ) );
  247. #define vout_Request(a,b,c) vout_Request(VLC_OBJECT(a),b,c)
  248.  
  249. /**
  250.  * This function will create a suitable vout for a given p_fmt. It will never
  251.  * reuse an already existing unused vout.
  252.  *
  253.  * You have to call either vout_Close or vout_Request on the returned value
  254.  * \param p_this a vlc object to which the returned vout will be attached
  255.  * \param p_fmt the video format requested
  256.  * \return a vout if the request is successfull, NULL otherwise
  257.  */
  258. VLC_EXPORT( vout_thread_t *, vout_Create, ( vlc_object_t *p_this, video_format_t *p_fmt ) );
  259. #define vout_Create(a,b) vout_Create(VLC_OBJECT(a),b)
  260.  
  261. /**
  262.  * This function will close a vout created by vout_Create or vout_Request.
  263.  * The associated vout module is closed.
  264.  * Note: It is not released yet, you'll have to call vlc_object_release()
  265.  * or use the convenient vout_CloseAndRelease().
  266.  *
  267.  * \param p_vout the vout to close
  268.  */
  269. VLC_EXPORT( void,            vout_Close,        ( vout_thread_t *p_vout ) );
  270.  
  271. /**
  272.  * This function will close a vout created by vout_Create
  273.  * and then release it.
  274.  *
  275.  * \param p_vout the vout to close and release
  276.  */
  277. static inline void vout_CloseAndRelease( vout_thread_t *p_vout )
  278. {
  279.     vout_Close( p_vout );
  280.     vlc_object_release( p_vout );
  281. }
  282.  
  283. /**
  284.  * This function will handle a snapshot request.
  285.  *
  286.  * pp_image, pp_picture and p_fmt can be NULL otherwise they will be
  287.  * set with returned value in case of success.
  288.  *
  289.  * pp_image will hold an encoded picture in psz_format format.
  290.  *
  291.  * i_timeout specifies the time the function will wait for a snapshot to be
  292.  * available.
  293.  *
  294.  */
  295. VLC_EXPORT( int, vout_GetSnapshot, ( vout_thread_t *p_vout,
  296.                                      block_t **pp_image, picture_t **pp_picture,
  297.                                      video_format_t *p_fmt,
  298.                                      const char *psz_format, mtime_t i_timeout ) );
  299.  
  300. /* */
  301. VLC_EXPORT( int,             vout_ChromaCmp,      ( uint32_t, uint32_t ) );
  302.  
  303. VLC_EXPORT( picture_t *,     vout_CreatePicture,  ( vout_thread_t *, bool, bool, unsigned int ) );
  304. VLC_EXPORT( void,            vout_DestroyPicture, ( vout_thread_t *, picture_t * ) );
  305. VLC_EXPORT( void,            vout_DisplayPicture, ( vout_thread_t *, picture_t * ) );
  306. VLC_EXPORT( void,            vout_LinkPicture,    ( vout_thread_t *, picture_t * ) );
  307. VLC_EXPORT( void,            vout_UnlinkPicture,  ( vout_thread_t *, picture_t * ) );
  308. VLC_EXPORT( void,            vout_PlacePicture,   ( const vout_thread_t *, unsigned int, unsigned int, unsigned int *, unsigned int *, unsigned int *, unsigned int * ) );
  309.  
  310. /**
  311.  * Return the spu_t object associated to a vout_thread_t.
  312.  *
  313.  * The return object is valid only as long as the vout is. You must not
  314.  * release the spu_t object returned.
  315.  * It cannot return NULL so no need to check.
  316.  */
  317. VLC_EXPORT( spu_t *, vout_GetSpu, ( vout_thread_t * ) );
  318.  
  319. void vout_IntfInit( vout_thread_t * );
  320. VLC_EXPORT( void, vout_EnableFilter, ( vout_thread_t *, const char *,bool , bool  ) );
  321.  
  322.  
  323. static inline int vout_vaControl( vout_thread_t *p_vout, int i_query,
  324.                                   va_list args )
  325. {
  326.     if( p_vout->pf_control )
  327.         return p_vout->pf_control( p_vout, i_query, args );
  328.     else
  329.         return VLC_EGENERIC;
  330. }
  331.  
  332. static inline int vout_Control( vout_thread_t *p_vout, int i_query, ... )
  333. {
  334.     va_list args;
  335.     int i_result;
  336.  
  337.     va_start( args, i_query );
  338.     i_result = vout_vaControl( p_vout, i_query, args );
  339.     va_end( args );
  340.     return i_result;
  341. }
  342.  
  343. enum output_query_e
  344. {
  345.     VOUT_SET_STAY_ON_TOP=1, /* arg1= bool       res=    */
  346.     VOUT_SET_VIEWPORT,      /* arg1= view rect, arg2=clip rect, res= */
  347.     VOUT_REDRAW_RECT,       /* arg1= area rect, res= */
  348. };
  349.  
  350. /**@}*/
  351.  
  352. #endif /* _VLC_VIDEO_H */
  353.